public class TestDAO extends MySQLHelper {
    public void addCustomer(Customer item) {
        try {
            getConnection();
            String sql = "insert into Customer(idCustomer, password, points) values(?, ?, ?)";
            callableStatement = connection.prepareCall(sql);
            callableStatement.setString(1, item.getId());
            callableStatement.setString(2, item.getPassword());
            callableStatement.setInt(3, item.getPoints());
            callableStatement.execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            closeAll();
        }
    }

    public void queryPoints(int points) {
        try {
            getConnection();
            String sql = "select idCustomer from Customer where points = ?";
            callableStatement = connection.prepareCall(sql);
            callableStatement.setInt(1, points);
            callableStatement.execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            closeAll();
        }
    }

    public int sum() {
        int num = 0;
        try {
            getConnection();
            String sql = "select count(*) from Customer";
            callableStatement = connection.prepareCall(sql);
            resultSet = callableStatement.executeQuery();
            if (resultSet.next()) {
                num = resultSet.getInt(1);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            closeAll();
        }
        return num;
    }
}
